<template>
	<scroll-view scroll-y  class="cont">
		<view class="cate-list">
			<view class="cate-item" @click="To_detail(item.id)" v-for="item in cateList" :key="item.id">
				<image :src="item.cover" mode="aspectFill"></image>
				<view class="cate-name">{{item.name}}</view>
			</view>
		</view>
	</scroll-view>
</template>

<script>
	import {cateList} from "@/api/cate"
	export default{
		data(){
			return{
				// 分类数组
				cateList:[]
			}
		},
		mounted() {
			// 标题修改
			uni.setNavigationBarTitle({
				title:"分类"
			})
			this.loadData()
		},
		methods:{
			loadData(){
				cateList().then(res=>{
					console.log("cate",res)
					this.cateList=res.res.category
				})
			},
			To_detail(id){
				uni.navigateTo({
					url:'/pages/cate/index?id='+id
				})
			}
		}
	}
</script>

<style lang="scss">
	.cont{
		height: calc(100vh - 70rpx);
	}
	.cate-list{
		display: flex;
		padding:20rpx;
		flex-wrap: wrap;
		justify-content: space-between;
		.cate-item{
			width: 33.33%;
			height: 240rpx;
			border: 5rpx solid #fff;
			position: relative;
			image{
				width: 100%;
				height: 100%;
			}
			.cate-name{
				position: absolute;
				font-weight: 600;
				color: #fff;
				bottom: 5rpx;
				left: 20rpx;
			}
		}
	}
</style>
